#include "stdafx.h"
#include "collada.h"

#ifdef _DEBUG
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
#define new DEBUG_NEW
#endif

using namespace Collada;

IMPLEMENT_RTTI( Collada::VisualScene, Collada::Element )
IMPLEMENT_ELEMENT( Collada::VisualScene )

VisualScene::VisualScene( const std::string& id, const std::string& name )
:	Element( id, name )
{
	CHILD_ELEMENT_BEGIN()
		CHILD_ELEMENT( "asset",				Collada::Empty )
		CHILD_ELEMENT( "node",				Collada::Node )
		CHILD_ELEMENT( "evaluate_scene",	Collada::Empty )
		CHILD_ELEMENT( "extra",				Collada::Empty )
	CHILD_ELEMENT_END()
}

VisualScene::~VisualScene()
{
	std::vector< Node* >::iterator it = _nodes.begin();
	for( ; it != _nodes.end(); ++it )
	{
		delete ( *it );
	}
}

bool VisualScene::AddNode( Node* pNode )
{
	_nodes.push_back( pNode );
	return true;
}

void VisualScene::AllChildElementsLoaded( Element* pParent )
{
	( ( Library* )pParent )->AddVisualScene( this );
}

void VisualScene::Initialize( Element* pParent, const void* desc )
{
	TiXmlElement* pElem = ( TiXmlElement* )desc;
}

bool VisualScene::IsValid( const void* desc )
{
	TiXmlElement* pElem = ( TiXmlElement* )desc;
	if( pElem->FirstChildElement( "node" ) )
	{
		return true;
	}

	return false;
}